class Route{
    //成员变量体现封装性
    private String name;
    private String[] stations;
    private String startStation;
    private String endStation;
    private double fare;
    private double distance;
    //不带参数的构造方法
    public Route() {

    }
    //带参数的构造方法
    public Route(String name, String[] stations, String startStation, String endStation) {
        this.name = name;
        this.stations = stations;
        this.startStation = startStation;
        this.endStation = endStation;
    }
    //set和get方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String[] getStations() {
        return stations;
    }
    public void setStations(String[] stations) {
        this.stations = stations;
    }
    public String getStartStation() {
        return startStation;
    }
    public void setStartStation(String startStation) {
        this.startStation = startStation;
    }
    public String getEndStation() {
        return endStation;
    }
    public void setEndStation(String endStation) {
        this.endStation = endStation;
    }
    public void setFare(double fare) {
        this.fare = fare;
    }
    public void setDistance(double distance) {
        this.distance = distance;
    }
    //查询路线的方法
    public void queryStations() {
        System.out.println(getName() + "的站点有：");
        for (String station : stations) {
            System.out.print(station+" ");
        }
        System.out.println();
    }
    public double getDistance() {
        // 计算距离的逻辑
        return stations.length * 10;
    }
    public double getFare() {
        // 计算费用的逻辑
        return stations.length * 1;
    }
}
public class Test {
    public static void main(String[] args) {
        //创建对象
       Route route1=new Route("101",new String[]{"S1","S2","S3","S4","S5"},"S1","S5");
       Route route2=new Route("102",new String[]{"S2","S3","S4","S5","S6"},"S2","S6");
       route1.queryStations();
       System.out.println("路程为："+route1.getDistance()+"  "+"费用为"+route1.getFare());
       route2.queryStations();
    }
}
